<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>商户资料</title> 
	<link href="__INDEX__/store/css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="__INDEX__/store/css/iconfont.css" />
	<link rel="stylesheet" href="__INDEX__/store/css/style.css" />
	<link rel="stylesheet" href="__INDEX__/store/css/member.css" />
	<link rel="stylesheet" href="__INDEX__/store/css/picker.css" />
	<link rel="stylesheet" href="__INDEX__/store/css/poppicker.css" />	
	<link rel="stylesheet" href="__INDEX__/store/css/datepicker3.css" />
	<script rel="stylesheet" src="__INDEX__/store/plugin/crop/croppie.min.js"></script>
	<link rel="stylesheet" href="__INDEX__/store/css/font-awesome.min.css" />
	<link rel="stylesheet" href="__INDEX__/store/css/bootstrap.min.css" />
<style type="text/css">
 .grzl_toux{position: relative;}
 /*#upload{opacity:0;filter:alpha(opacity=0);height: 95px; width: 100px;position: absolute;top: -80px;left: -40px;z-index: 9;}*/
/*.btn_thumb{opacity:0;filter:alpha(opacity=0);height: 95px; width: 100px;position: absolute;top: -0px;left: -0px;z-index: 9;}*/
    </style>
</head>
<body>
	<header class="mui-bar mui-bar-nav">
	    <a class="mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
	    <h1 class="mui-title">商户资料</h1>
	</header>
	<div class="mui-content ">
	   	<div class="gerenzl_nr">
	   		 <form class="mui-input-group gerenzl_group layui-form update_form">
				<div class="gerenzl_top img-click">
					<div class="actions" style="text-align: center; padding-top: 20px;">
						<button id="test1" type="button" class="file-btn" style="height:78px;width:78px;border-radius: 100%;">
		   		 		<div class="layui-upload">
						  <div class="layui-upload-list" style="margin: unset;">
						    <img class="layui-upload-img" style="height:78px;width:78px;border-radius: 100%;" id="logo" src="{$agent_info['logo']?$agent_info['logo']:'/public/static/index/store/images/member.jpg'}">
						    <input type="hidden" name='logo' value="{$agent_info['logo']}" id='thumb' />
						    <p id="demoText"></p>
						  </div>
						</div>  
						</button>
						<div style="font-size: 15px; line-height: 1.5rem; margin: 10px 0px;">商户LOGO</div>
					</div>
				</div>
				
				<div style="height:5px;background-color: #EFEFF4;"></div>
				<div class="mui-input-row ">
					<label><em>*</em>店铺名称</label>
					<input type="text" id="agent_name" name="agent_name" value="{$agent_info['agent_name']}" class="mui-input-group" placeholder="店铺名称">					
				</div>
				<div class="mui-input-row">
					<label><em>*</em>店铺号码</label>
					<input type="text" id="tel" name="tel" value="{$agent_info['tel']}" class="mui-input-group" placeholder="店铺号码"  >					
				</div>
				<div class="mui-input-row">
					<label><em>*</em>营业时间</label>
					<div class="htrig_con">
		       			<input  name='start_time' id="date2" value="{$agent_info['start_time']}" onclick="WdatePicker({dateFmt:'HH-mm-ss'})" type='text' placeholder="开始时间" style="border: 0;width: 33%;" />
		        		<input  name='end_time' id="date3" value="{$agent_info['end_time']}" onclick="WdatePicker({dateFmt:'HH-mm-ss'})" type='text' placeholder="结束时间" style="border: 0;width: 33%;" />
					</div>				
				</div>	
				<div class="mui-input-row">
					<label><em>*</em>店铺活动</label>
					<input type="text" id="action" name="action" value="{$agent_info['action']}" class="mui-input-group" placeholder="店铺活动">
				</div>
				<div class="mui-input-row">
					<label><em>*</em>店铺简介</label>
				</div>
				<div>			
					<div id="div1" class="toolbar" style="background-color: #d4cece;"></div>
		    		<div id="div2" class="text" style="height: 450px;background-color: #f7f7f7;" ></div>
		    		<textarea  name="content"  id="content" style="display: none;"></textarea>
				</div>			
				<div style="position: relative; text-align: center; line-height: 80px; height: 80px;">
					<button type="button" lay-submit lay-filter="submit_form" class="layui-btn" style="background: #1DAA39;">保存</button>
				</div>
			</form>
	   	</div>
	   	<input type="hidden" id="store_id" >
	</div>

</body>
</html>
{include file="public/footer" /}
<script type="text/javascript" src="__PUBLIC__/static/release/wangEditor.min.js"></script>
<script>
	//图片上传
	layui.use(['form','upload','laydate'], function(){
  		var $ = layui.jquery,upload = layui.upload,form = layui.form;
  		laydate = layui.laydate;
  		//监听表单提交
		form.on('submit(submit_form)', function(data){
			$("#content").val(editor1.txt.html());
			tijiao();
  			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});
	laydate.render({
	    elem: '#date2',
	    type:'time'
  	});
  	laydate.render({
	    elem: '#date3',
	    type:'time'
  	});	
  		//富文本编辑器
  		var uploadInst_1 = upload.render({
			elem: '#test1'
		    ,auto: false //选择文件后不自动上传
		    ,choose: function(obj){
			    //将每次选择的文件追加到文件队列
			    var files = obj.pushFile();
			    //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
			    obj.preview(function(index, file, result){
			    	$('#logo').attr('src', result); //图片链接（base64）
			    	var sendData = result.substring(result.indexOf(";base64,")+8);
			    	$.post("{:url('agent/index/upload')}",{value:sendData},function(data){ 
	                            if(data.code == '200'){  
	                            	$('#thumb').val(data.url);
	                            }else{  
	                                layer.msg(data.msg);
	                            }  
                    		});
			    });
			}
		    ,url: "{:url('index/upload')}"
		    ,accept:'images'
		});
	});
	var E = window.wangEditor;
    var editor1 = new E('#div1', '#div2');
    editor1.customConfig.uploadImgServer="wang_upload"; 
    editor1.customConfig.uploadImgHooks = {
    	customInsert: function (insertImg, result, editor) {
        var url = result.src;
        insertImg(url)
    	}
    }
    editor1.customConfig.menus = [
        'source',
        '|',
        'bold',
        'underline',
        'italic',
        'strikethrough',
        'eraser',
        'forecolor',
        'bgcolor',
        '|',
        'quote',
        'fontfamily',
        'fontsize',
        'head',
        'unorderlist',
        'orderlist',
        'alignleft',
        'aligncenter',
        'alignright',
        '|',
        'link',
        'unlink',
        'table',
        'emotion',
        '|',
        'img',
        'video',
        'location',
        'insertcode',
        '|',
        'undo',
        'redo',
        'fullscreen'
     ];
    editor1.create();
	editor1.txt.html('{$agent_info.content}');
	
	//提交表单
	function tijiao(){
		var myreg = /^1[3578]\d{9}$/; 
	    var mobile =  $("#tel").val();
	    if(!myreg.test(mobile)){
	    	layer.msg('请输入有效的手机号码！'); 
	    	return false;
	    }
		
  		$.ajax({
         	type:"post",
            url:"{:url('agent/agent')}",
            data: $('.layui-form').serialize(),//表单数据
            success:function(data){
				layer.msg(data.msg, {
					icon: 1,
					time: 1500 //2秒关闭（如果不配置，默认是3秒）
				}, function() {
					location.href='agent.html';
				});
            },error:function(data){
            	var a = data;
            }
        });
  		
  	}
</script>